﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="ValidateStudentRegistration.Register" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Student Registration</title>
</head>
<body>
    <form id="registrationForm" runat="server">
    <div>
    
        Logon Information:<br />
    
        Username:
        <asp:TextBox ID="txtUserName" runat="server" 
            ValidationGroup="validationGroupLogonInfo"></asp:TextBox>
        <asp:RequiredFieldValidator ID="userNameReuqiredValidator"
            runat="server" 
            ControlToValidate="txtUserName"
            ErrorMessage="Username is required" 
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationGroupLogonInfo"></asp:RequiredFieldValidator>

        <br />
        Password:
        <input type="password" ID="txtPassword" runat="server" 
            validationgroup="validationGroupLogonInfo" />
        <asp:RequiredFieldValidator ID="passwordRequiredValidator"
            runat="server" 
            ControlToValidate="txtPassword"
            ErrorMessage="Password is required" 
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationGroupLogonInfo"></asp:RequiredFieldValidator>

        <br />
        Repeat Password:
        <input type="password" ID="txtRepeatPass" runat="server" 
            validationgroup="validationGroupLogonInfo" />
        <asp:RequiredFieldValidator ID="repeatPassRequiredValidator"
            runat="server" 
            ControlToValidate="txtRepeatPass"
            ErrorMessage="You have not repeated the password" 
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationGroupLogonInfo"></asp:RequiredFieldValidator>&nbsp;
        <asp:CompareValidator ID="comparePasswordsValidator"
            runat="server"
            ControlToValidate="txtRepeatPass"
            ControlToCompare="txtPassword"
            ValueToCompare="Text"
            ErrorMessage="The passwords don't match"
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationGroupLogonInfo"></asp:CompareValidator>

        <br />
        Email:
        <asp:TextBox ID="txtEmail" runat="server" 
            ValidationGroup="validationGroupLogonInfo"></asp:TextBox>
        <asp:RequiredFieldValidator ID="emailRequiredValidator"
            runat="server" 
            ControlToValidate="txtEmail"
            ErrorMessage="Email is required" 
            Display="Dynamic"
            ForeColor="Red"></asp:RequiredFieldValidator>&nbsp;
        <asp:RegularExpressionValidator ID="emailRegularExpressionValidator"
            runat="server"
            ControlToValidate="txtEmail"
            ValidationExpression="^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
            ErrorMessage="Invalid email"
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationGroupLogonInfo"></asp:RegularExpressionValidator>

        <br />
        <asp:Button ID="btnLogonInfoValidate" runat="server" Text="Validate" 
            ValidationGroup="validationGroupLogonInfo" />
        <br />
        <br />
        Personal Information:<br />
        First Name:
        <asp:TextBox ID="txtFirstName" runat="server" 
            ValidationGroup="validationGroupPersonalInfo"></asp:TextBox>
        <asp:RequiredFieldValidator ID="firstNameRequiredValidator"
            runat="server" 
            ControlToValidate="txtFirstName"
            ErrorMessage="First name is required" 
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationGroupPersonalInfo"></asp:RequiredFieldValidator>

        <br />
        Last Name:
        <asp:TextBox ID="txtLastName" runat="server" 
            ValidationGroup="validationGroupPersonalInfo"></asp:TextBox>
        <asp:RequiredFieldValidator ID="lastNameRequiredValidator"
            runat="server" 
            ControlToValidate="txtLastName"
            ErrorMessage="Last name is required" 
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationGroupPersonalInfo"></asp:RequiredFieldValidator>

        <br />
        Age:
        <asp:TextBox ID="txtAge" runat="server" Width="31px" 
            ValidationGroup="validationGroupPersonalInfo"></asp:TextBox>
        <asp:RequiredFieldValidator ID="ageRequiredValidator"
            runat="server" 
            ControlToValidate="txtAge"
            ErrorMessage="Age is required" 
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationGroupPersonalInfo"></asp:RequiredFieldValidator>&nbsp;
        <asp:RangeValidator ID="ageRangeValidator"
            runat="server"
            ControlToValidate="txtAge"
            MinimumValue="18"
            MaximumValue="81"
            ErrorMessage="The age should be between 18 and 80"
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationGroupPersonalInfo"></asp:RangeValidator>

        <br />
        Gender:
        <asp:RadioButton ID="radioBtnMaleGender" runat="server" GroupName="Gender" 
            Text="Male" AutoPostBack="True" 
            oncheckedchanged="radioBtnMaleGender_CheckedChanged" />
&nbsp;<asp:RadioButton ID="radioBtnFemaleGender" runat="server" GroupName="Gender" 
            Text="Female" AutoPostBack="True" 
            oncheckedchanged="radioBtnFemaleGender_CheckedChanged" />
        <br />
        <asp:Label ID="lblChooseCars" runat="server" 
            Text="Choose your favourite cars:" Visible="False"></asp:Label>
        <asp:CheckBoxList ID="checkBoxListCars" runat="server" 
            ValidationGroup="validationGroupPersonalInfo" Visible="False">
            <asp:ListItem>BMW</asp:ListItem>
            <asp:ListItem>Toyota</asp:ListItem>
            <asp:ListItem>Mercedes</asp:ListItem>
            <asp:ListItem>Ford</asp:ListItem>
            <asp:ListItem>Audi</asp:ListItem>
        </asp:CheckBoxList>

        <asp:Label ID="lblChooseCoffee" runat="server" Enabled="False" 
            Text="Choose your favourite coffee:" Visible="False"></asp:Label>
        <br />
        <asp:DropDownList ID="dropDownListCoffee" runat="server" Visible="False">
            <asp:ListItem>Lavazza</asp:ListItem>
            <asp:ListItem>New Brazil</asp:ListItem>
            <asp:ListItem>Jacobs</asp:ListItem>
            <asp:ListItem>Pesho&#39;s Coffee</asp:ListItem>
        </asp:DropDownList>
        <br />
        <br />
        <asp:Button ID="btnPersonalInfoValidate" runat="server" Text="Validate" 
            ValidationGroup="validationGroupPersonalInfo" />
        <br />
        <br />
        Address Information:<br />
        Local Address:
        <asp:TextBox ID="txtLocalAddress" runat="server" 
            ValidationGroup="validationAddressInfo"></asp:TextBox>
        <asp:RequiredFieldValidator ID="localAddressRequiredValidator"
            runat="server" 
            ControlToValidate="txtLocalAddress"
            ErrorMessage="Local address is required" 
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationAddressInfo"></asp:RequiredFieldValidator>

        <br />
        Phone Number:
        <asp:TextBox ID="txtPhoneNumber" runat="server" 
            ValidationGroup="validationAddressInfo"></asp:TextBox>
        <asp:RequiredFieldValidator ID="phoneNumberRequiredValidator"
            runat="server" 
            ControlToValidate="txtPhoneNumber"
            ErrorMessage="Phone number is required" 
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationAddressInfo"></asp:RequiredFieldValidator>&nbsp;
        <asp:RegularExpressionValidator ID="phoneNumberRegularExpressionValidator"
            runat="server"
            ControlToValidate="txtPhoneNumber"
            ValidationExpression="^([\(]{1}[0-9]{3}[\)]{1}[\.| |\-]{0,1}|^[0-9]{3}[\.|\-| ]?)?[0-9]{3}(\.|\-| )?[0-9]{4}$"
            ErrorMessage="The phone number should be 7 digits"
            Display="Dynamic"
            ForeColor="Red" ValidationGroup="validationAddressInfo"></asp:RegularExpressionValidator>

        <br />
        <asp:Button ID="btnAddressInfoValidate" runat="server" Text="Validate" 
            ValidationGroup="validationAddressInfo" />
        <br />

        <br />
        <asp:CheckBox ID="checkBoxAccept" runat="server" Text="I accept" 
            oncheckedchanged="checkBoxAccept_CheckedChanged"
            AutoPostBack="true" />
        <br />
        <br />
        <asp:Button ID="btnRegister" runat="server" Text="Register" 
            onclick="btnRegister_Click" Enabled="False" />
    
        <br />
        <br />
        <asp:Literal ID="ltMessage" runat="server" 
            Text="&lt;h2&gt;Registration successfull!&lt;/h2&gt;" Visible="False"></asp:Literal>
    
    </div>
    </form>
</body>
</html>
